package case1.decorator;

import case1.Quackable;
import case1.core.observer.Observable;
import case1.core.observer.Observer;

/***
 * description:
 * 装饰器模式拓展类行为
 * @author Yuanml
 * @date 2020/10/30 上午11:08
 **/
public class QuackCounter implements Quackable {
    public static int count = 0;
    private Quackable quackable;
    private final Observable observable;
    public QuackCounter(Quackable quackable) {
        this.quackable = quackable;
        observable = new Observable(this);
    }
    @Override
    public void quack() {
        count++;
        quackable.quack();
        notifyObserver();
    }

    @Override
    public void registerObserver(Observer observer) {
        observable.registerObserver(observer);
    }

    @Override
    public void notifyObserver() {
        observable.notifyObserver();
    }
}
